package com.rabbitmq.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MutiplyMessageConfig {

	public static final String mutiplyExchange="mutiply-exchange";

	public  static final String mutiplyQueue1="mutiply-queue1";

	public static final String mutiplyQueue2="mutiply-queue2";

	public static final String  mutiplyKey="mutipley-key";


	public static final String mutiplyFanoutExchange="mutiply-fanout-exchange";


	public  static final String mutiplyFanoutQueue1="mutiply-fanout-queue1";

	public static final String mutiplyFanoutQueue2="mutiply-fanout-queue2";


	@Bean
	public DirectExchange createMutiplyDirectExchange(){
		return new DirectExchange(MutiplyMessageConfig.mutiplyExchange);
	}
//	@Bean
//	public TopicExchange createMutiplyDirectExchange(){
//		return new TopicExchange(MutiplyMessageConfig.mutiplyExchange);
//	}


	@Bean
	public FanoutExchange createMutiplyFanoutExchange(){
		return new FanoutExchange(MutiplyMessageConfig.mutiplyFanoutExchange);
	}

	@Bean
	public Queue createMutiplyQueue1(){
		return  new Queue(MutiplyMessageConfig.mutiplyQueue1,true,false,false);
	}

	@Bean
	public Queue createMutiplyQueue2(){
		return  new Queue(MutiplyMessageConfig.mutiplyQueue2,true,false,false);
	}

	@Bean
	Binding binding1() {
		return BindingBuilder.bind(createMutiplyQueue1()).to(createMutiplyDirectExchange()).with(MutiplyMessageConfig.mutiplyKey);
	}

	@Bean
	Binding binding2() {
		return BindingBuilder.bind(createMutiplyQueue2()).to(createMutiplyDirectExchange()).with(MutiplyMessageConfig.mutiplyKey);
	}

	@Bean
	public Queue createFaloutQueue1(){
		return  new Queue(MutiplyMessageConfig.mutiplyFanoutQueue1,true,false,false);
	}

	@Bean
	public Queue createFaloutQueue2(){
		return  new Queue(MutiplyMessageConfig.mutiplyFanoutQueue2,true,false,false);
	}

	@Bean
	Binding binding3() {
		return BindingBuilder.bind(createFaloutQueue1()).to(createMutiplyFanoutExchange());
	}


	@Bean
	Binding binding4() {
		return BindingBuilder.bind(createFaloutQueue2()).to(createMutiplyFanoutExchange());
	}
}
